package com.nbsaas.boot.otp.ext.resource;

public class OtpServiceTest {
    public static void main(String[] args) throws Exception {
        OtpService otpService = new OtpService();
 
        // 使用 Base32 编码密钥
        String secret = "JBSWY3DPEHPK3PXP";
        String userId = "user123";
 
        // 生成 OTP
        String otp = otpService.generateTOTP(secret)+"1";
        System.out.println("Generated OTP: " + otp);
 
        // 尝试验证 OTP
        for (int i = 0; i < 7; i++) {
            boolean isValid = otpService.validateTOTP(secret, otp, userId);
            System.out.println("Attempt " + (i + 1) + ": Is OTP valid: " + isValid);
        }
    }
}